package com.example.libraryapp.activity.borrowHistory;

import com.example.libraryapp.bean.BookBorrow;
import com.example.libraryapp.bean.response.BaseResponse;
import com.example.libraryapp.network.base.BaseHttpHandler;
import com.example.libraryapp.network.base.BasePresenter;

import java.util.List;

/**
 * @author 伍凯铭
 * @since 2020/6/28
 */
public class BorrowHistoryPresentIml extends BasePresenter<BorrowHistoryContract.View> implements BorrowHistoryContract.Presenter{

    @Override
    public void getBorrowHistory(long userId) {
        super.doRequest(getRequestService().getBorrowHistory(userId),new BorrowHistoryHandler());
    }

    class BorrowHistoryHandler extends BaseHttpHandler<BaseResponse<List<BookBorrow>>> {

        BorrowHistoryHandler() {
            super(mView);
        }

        @Override
        public void onSuccess(BaseResponse<List<BookBorrow>> response) {
            if(mView != null) {
                mView.showContent();
                mView.showBorrowHistory(response);
            }
        }
    }
}
